Caption = "Please feel free to modify this code in any way you please. If you make any signifigant improvements, upload the files. Suggestions: 3D effects for the Form, more tab styles, multiple focus (one for each row),"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 855
Index = 38
Left = 480
TabIndex = 46
Top = 3120
Width = 4815
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "Since this control is VB source code and freely modifiable by the user, I didn't feel it was necessary to anticipate every possible usage. Most of this kind of code would need to be removed each time it was used.. For example, the Resize code can be removed if your forms are not sizable."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 1095
Index = 37
Left = 480
TabIndex = 45
Top = 1920
Width = 4815
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "This control is Freeware. It is based on a similar control written by James Parr and uploaded to compuserve. It is 100% VB code, no DLL's, no VBX's, yet it should perform about as well. This control adds 3D effects, multiple instances, and mixed control types for pages."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 1095
Index = 36
Left = 480
TabIndex = 44
Top = 720
Width = 4815
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "V. About this control."
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 12
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 35
Left = 120
TabIndex = 43
Top = 120
Width = 5295
End
End
Begin PictureBox PicBox
BackColor = &H00C0C0C0&
Height = 4215
Index = 4
Left = 1200
ScaleHeight = 4185
ScaleWidth = 5625
TabIndex = 6
Tag = "Step 4"
Top = 600
Width = 5655
Begin Label l
BackStyle = 0 'Transparent
Caption = "The tab control is generated by first drawing one tab in the proper size and orientation (invbox) and then blitting this picture to the visible picturebox (tabbox). Rescaling and StretchBlting seemed even more cumbersome than the method used. When a tab is clicked, only the tab captions and the focus line are redrawn. While the speed could be improved a little, the response of the control seems to depend more on the pages and their contents at this point than on the tab element."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 1695
Index = 34
Left = 480
TabIndex = 42
Top = 2280
Width = 4815
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "Run the project and examine the control. The code controlling the graphic appearance is in DrawTabs(). TabClick() controls the behavior of the tabs when clicked. Try resetting the tb.num and tb.cols values. Note that unused spaces are filled with unlabeled tabs; this was done because of the awkward effect produced when a partial row was moved beneath a full row, so be prepared to tackle this problem if you wish to eliminate unused tabs."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 1455
Index = 33
Left = 480
TabIndex = 41
Top = 720
Width = 4815
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "IV. That's it!"
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 12
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 32
Left = 120
TabIndex = 40
Top = 120
Width = 5295
End
End
Begin PictureBox PicBox
BackColor = &H00C0C0C0&
Height = 4215
Index = 3
Left = 1080
ScaleHeight = 4185
ScaleWidth = 5625
TabIndex = 5
Tag = "Step 3"
Top = 600
Width = 5655
Begin Label l
BackStyle = 0 'Transparent
Caption = "Size the first member of the page() array to the proper size. All the pages will be resized automatically to match it, and the tabbox and Form will be resized to fit it. See the other samples for examples of how to position the tabs on other types of Forms."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 975
Index = 31
Left = 480
TabIndex = 39
Top = 720
Width = 4815
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "If Keycode = H22 then NextPage"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 30
Left = 480
TabIndex = 38
Top = 3840
Width = 3855
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "If Keycode = H21 then PrevPage"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 29
Left = 480
TabIndex = 37
Top = 3600
Width = 3855
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "tb.orient = 1 ' 0 = up, 1 = down"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 28
Left = 480
TabIndex = 36
Top = 2760
Width = 3855
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "III. Set additional properties."
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 12
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 27
Left = 120
TabIndex = 35
Top = 120
Width = 5295
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "If you wish to handle keyboard events, add code such as the following to the Form's KeyDown event."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 495
Index = 22
Left = 480
TabIndex = 8
Top = 3120
Width = 4935
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "If you want the tabs to appear below the pages, add the following line to Form_Load before calling DefineControl():"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 495
Index = 21
Left = 480
TabIndex = 9
Top = 2280
Width = 4935
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "If you wish to set the Font properties of the tab captions, set the properties of the tabbox picturebox to the desired settings."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 495
Index = 20
Left = 480
TabIndex = 10
Top = 1680
Width = 4935
End
End
Begin PictureBox PicBox
BackColor = &H00C0C0C0&
Height = 4215
Index = 1
Left = 120
ScaleHeight = 4185
ScaleWidth = 5625
TabIndex = 3
Tag = "Step 1"
Top = 600
Width = 5655
Begin Label l
BackStyle = 0 'Transparent
Caption = "I. Creating the controls."
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 12
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 25
Left = 120
TabIndex = 33
Top = 120
Width = 5295
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "4. Set the tag property of each pictuebox to the text you want to appear on the tab for this page. Add whatever controls you want on each page to the appropriate PicBox().."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 735
Index = 7
Left = 480
TabIndex = 22
Top = 3240
Width = 4695
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "3. Create a control array of 6 pictureboxes. (Any control which can act as container can be used instead of pictureboxes.) These are the 'pages'. On this Form, they are PicBox(0) - PicBox(5)."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 855
Index = 6
Left = 480
TabIndex = 21
Top = 2280
Width = 4695
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "2. Set borderstyle=0 and scalemode=3 on both pictureboxes. Set visible=False on the child picturebox (invbox). Set the backcolor of both boxes and the Form to light grey"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 615
Index = 5
Left = 480
TabIndex = 20
Top = 1440
Width = 4695
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "1. Create a picturebox. Create a second picturebox within the first. On this Form, they are named 'tabbox' and 'invbox'."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 495
Index = 4
Left = 480
TabIndex = 19
Top = 720
Width = 4695
End
End
Begin PictureBox PicBox
BackColor = &H00C0C0C0&
Height = 4215
Index = 2
Left = 120
ScaleHeight = 4185
ScaleWidth = 5625
TabIndex = 4
Tag = "Step 2"
Top = 600
Width = 5655
Begin Label l
BackStyle = 0 'Transparent
Caption = "II. Adding the code."
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 12
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 26
Left = 120
TabIndex = 34
Top = 120
Width = 5295
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "3. Add the follwing line to the tabbox_Paint event:"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 19
Left = 480
TabIndex = 11
Top = 3480
Width = 4335
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "DrawText tabbox, page(), tb"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 18
Left = 480
TabIndex = 12
Top = 3720
Width = 3015
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "TabClick Button, X, Y, tabbox, page(), tb"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 17
Left = 480
TabIndex = 13
Top = 3120
Width = 4695
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "3. Add the follwing line to the tabbox_MouseUp event:"
Caption = "For i = 0 to 5: Set page(i) = PicBox(i): Next"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 13
Left = 480
TabIndex = 28
Top = 2040
Width = 4815
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "ReDim page(0 to 5)"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 12
Left = 480
TabIndex = 27
Top = 1800
Width = 3015
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "2. Add the following lines to the Form_Load event:"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 11
Left = 480
TabIndex = 26
Top = 1560
Width = 3615
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "Dim tb as TabData"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 10
Left = 480
TabIndex = 25
Top = 1200
Width = 3015
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "Dim page() as control"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 9
Left = 480
TabIndex = 24
Top = 960
Width = 3015
End
Begin Label l
BackStyle = 0 'Transparent
Caption = "1. Add the following lines to the general declarations section:"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 8
Left = 480
TabIndex = 23
Top = 720
Width = 4455
End
End
Begin PictureBox PicBox
BackColor = &H00C0C0C0&
Height = 4215
Index = 0
Left = 720
ScaleHeight = 4185
ScaleWidth = 5625
TabIndex = 2
Tag = "Intro"
Top = 600
Width = 5655
Begin Label l
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
BackStyle = 0 'Transparent
Caption = "Several pictureboxes or frames --------->"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 24
Left = 600
TabIndex = 32
Top = 1440
Width = 2895
End
Begin Label l
Alignment = 1 'Right Justify
BackColor = &H00C0C0C0&
BackStyle = 0 'Transparent
Caption = "2 Pictureboxes --------->"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 23
Left = 1800
TabIndex = 31
Top = 1080
Width = 1695
End
Begin Image Image1
Height = 1095
Left = 3600
Picture = DIALOG.FRX:0000
Top = 840
Width = 1575
End
Begin Label l
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = " The following tabs explain the steps required to create this sample."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Index = 3
Left = 120
TabIndex = 18
Top = 3840
Width = 5295
End
Begin Label l
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = " To handle events, add function calls to the KeyPress and Resize events of your Form, and to the MouseUp and Paint events of the tab picturebox."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 495
Index = 2
Left = 120
TabIndex = 17
Top = 3120
Width = 5415
End
Begin Label l
Alignment = 2 'Center
BackColor = &H00C0C0C0&
BackStyle = 0 'Transparent
Caption = "The tab 'control' consists of 2 picture boxes and whatever other controls are needed to implement each 'page':"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 495
Index = 0
Left = 120
TabIndex = 16
Top = 240
Width = 5415
End
Begin Label l
Alignment = 2 'Center
BackColor = &H00C0C0C0&
BackStyle = 0 'Transparent
Caption = " To create an instance of the tab control, you must declare a page array, a TabData structure, and create the picture boxes and page controls. You then need only call DefineControl() and pass these elements as parameters."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 735
Index = 1
Left = 120
TabIndex = 15
Top = 2160
Width = 5415
End
End
Begin Line ln
BorderColor = &H00FFFFFF&
Index = 7
X1 = 4320
X2 = 4320
Y1 = 5280
Y2 = 5040
End
Begin Line ln
BorderColor = &H00FFFFFF&
Index = 6
X1 = 3960
X2 = 4200
Y1 = 5280
Y2 = 5280
End
Begin Line ln
BorderColor = &H00808080&
Index = 5
X1 = 3840
X2 = 3840
Y1 = 5280
Y2 = 5040
End
Begin Line ln
BorderColor = &H00808080&
Index = 4
X1 = 4200
X2 = 3840
Y1 = 5040
Y2 = 5040
End
Begin Line ln
BorderColor = &H00808080&
Index = 3
X1 = 5880
X2 = 5880
Y1 = 0
Y2 = 3000
End
Begin Line ln
BorderColor = &H00808080&
Index = 2
X1 = 0
X2 = 3000
Y1 = 4920
Y2 = 4920
End
Begin Line ln
BorderColor = &H00FFFFFF&
Index = 1
X1 = 0
X2 = 0
Y1 = 0
Y2 = 3000
End
Begin Line ln
BorderColor = &H00FFFFFF&
Index = 0
X1 = 0
X2 = 3000
Y1 = 0
Y2 = 0
End
Option Explicit
Dim page() As control
Dim tb As TabData
Sub Form_Load ()
InitializeTabs
End Sub
Sub Form_Resize ()
'this draws 3d lines on the form
Dim l%, t%, w%, h%
h% = scaleheight - screen.TwipsPerPixelY
w% = scalewidth - screen.TwipsPerPixelX
ln(0).X2 = w
ln(1).Y2 = h
ln(2).Y1 = h
ln(2).Y2 = h
ln(2).X2 = w
ln(3).X1 = w
ln(3).X2 = w
ln(3).Y2 = h
l% = page(0).left - screen.TwipsPerPixelX
t% = page(0).top - screen.TwipsPerPixelY
w% = l + page(0).Width + screen.TwipsPerPixelX
h% = t + page(0).Height + screen.TwipsPerPixelY
ln(4).X1 = l
ln(4).X2 = w
ln(4).Y1 = t
ln(4).Y2 = t
ln(5).X1 = l
ln(5).X2 = l
ln(5).Y1 = t
ln(5).Y2 = h
ln(6).X1 = l
ln(6).X2 = w
ln(6).Y1 = h
ln(6).Y2 = h
ln(7).X1 = w
ln(7).X2 = w
ln(7).Y1 = t
ln(7).Y2 = h
End Sub
Sub InitializeTabs ()
Dim i%, numpages%
numpages = 5 'set to highest index (total-1)
'===create an array of controls ========================
ReDim page(0 To numpages)
For i = 0 To numpages: Set page(i) = PicBox(i): Next
'===fill in the fields of the struct=====================
tb.num = numpages 'number of tabs
tb.active = 0 'initial focus
tb.cols = 3 'number of tabs in each row
tb.orient = tabsup '0 = up, 1 = down
'vb won't always reinitialize these to 0
tb.left = 0
tb.top = 0
tb.Width = 0
tb.Height = 0
DefineControl Me, tabbox, invbox, page(), tb
End Sub
Sub tabbox_MouseUp (Button As Integer, Shift As Integer, x As Single, y As Single)